<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\helpers\ArrayHelper;
use yii\helpers\Url;

/* @var $this yii\web\View */
/* @var $model backend\models\Category */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="category-form">

    <?php 
    
    if($model->isNewRecord){
        
        $actionUrl = Url::to(['category/create']);
    }else{
        
        $actionUrl = Url::to(['category/update','id'=>$model->id]);
    }
    $form = ActiveForm::begin([
        'action' => $actionUrl,           //此处为请求地址 Url用法查看手册
        'id' =>"form-unique",
       // 'options' => ['onSubmit'=>' ajaxSubmit(this,"'.Url::toRoute("/category/create").'");return false;'],
    ]);

    ?>
    
  
    
    <?= $form->field($model, 'pid')->dropDownList(empty($data)?array(array()):ArrayHelper::map(array_merge([['id'=>'0','title'=>'项级父类']],$data), "id", "title"));?>
    
    <?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
    
    <?= $form->field($model, 'title')->textInput(['maxlength' => true]) ?>
    
     <?= $form->field($model, 'keywords')->textInput(['maxlength' => true]) ?>
    
     <?= $form->field($model, 'description')->textInput(['maxlength' => true]) ?>

    <?= $form->field($model, 'status')->dropDownList(ArrayHelper::map(array(
        array(
            'key'=>"1",
            'value'=>'开启',
        ),
        array(
            'key'=>"0",
            'value'=>'关闭',
        ),
        
        
    ),"key","value")); ?>
    
    <div class="form-group">
<?php


    if(!$model->isNewRecord){

        echo $form->field($model, 'id')->textInput(['maxlength' => true])->hiddenInput()->label("");
    }
    

 echo Html::submitButton($model->isNewRecord?"创建":"更新",['class' => 'btn btn-primary btn-ajax','data-method'=>'POST']);

?>

    </div>
    
  

    <?php ActiveForm::end(); ?>

      
 
</div>